package main

import (
	"fmt"
	"math"
	"math/cmplx"
)

// 基本数据类型：bool string int  byte rune(char) float32 float64 complex64 complex128
var (
	aa = 1
	bb = 2
	cc = 3
)

func variable() {
	var a int
	var s string
	fmt.Printf("%d, %q\n", a, s)
}

func variableOf() {
	a, b, c := 1, 2, 3
	fmt.Printf("%d,%d,%d,\n", a, b, c)
}

func euler() {
	fmt.Println(cmplx.Exp(1i*math.Pi) + 1)
}

func triangle() {
	var a, b = 3, 4
	var c int
	c = int(math.Sqrt(float64(a*a + b*b)))
	fmt.Println(c)
}

func constants() {
	const filename = "abc.txt"
	const a, b = 3, 4
	var c int
	c = int(math.Sqrt(a*a + b*b))
	fmt.Println(filename, c)
}

func enums() {
	const (
		cpp = iota
		_
		python
		golang
		javascript
	)

	const (
		b = 1 << (10 * iota)
		kb
		mb
		gb
		tb
		pb
	)

	fmt.Println(cpp, javascript, python, golang)
	fmt.Println(b, kb, mb, gb, tb, pb)
}

func main() {
	fmt.Println("hello world")
	variable()
	variableOf()
	fmt.Println(aa, bb, cc)
	// 欧拉公式
	euler()
	// 类型转化是强制
	triangle()
	// 常量
	constants()
	// 枚举
	enums()
}
